package com.contactbook.web.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class DialogBoxWidget extends DialogBox {
	
	private ContactBook contactBook;
	
	public DialogBoxWidget(ContactBook contactBook, String message) {
		
		super();
		
		this.contactBook = contactBook;
		
		setText("Message");
		setAnimationEnabled(true);
		final Button closeButton = new Button("OK");
		closeButton.getElement().setId("closeButton");
		closeButton.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				hide();
			}
		});
		VerticalPanel dialogVPanel = new VerticalPanel();
		dialogVPanel.addStyleName("dialogVPanel");
		final Label response = new Label();
		response.setText(message);
		dialogVPanel.add(response);
		dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
		dialogVPanel.add(closeButton);
		setWidget(dialogVPanel);
		center();
		show();
	}
	
	public void onHide(String viewName) {
		contactBook.switchView(viewName);
	}
}
